import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:winkai/entity/role_info.dart';
import 'package:winkai/ext/screen_ext.dart';
import 'package:winkai/utils/net_image_load_utils.dart';
import 'package:winkai/widget/custom_style_bg.dart';

class UserDetailsInfoWidget extends StatelessWidget {
  const UserDetailsInfoWidget({super.key, required this.roleInfo});

  final RoleInfo roleInfo;

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        _buildImageWidget(),
        SizedBox(height: 14.w),
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Flexible(
              child: Text(
                roleInfo.name ?? '',
                style: TextStyle(
                  fontSize: 27.sp,
                  color: Colors.black,
                  fontFamily: 'LexendDeca-Black',
                  fontWeight: FontWeight.w800,
                ),
              ),
            ),
            SizedBox(width: 4.w),
            CustomStyleBg(
              width: 41.w,
              height: 24.w,
              child: Text(
                roleInfo.age.toString(),
                style: TextStyle(
                  fontSize: 14.sp,
                  color: Colors.black,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
          ],
        ),
        SizedBox(height: 4.w),
        SizedBox(
          width: double.infinity,
          child: Text(
            roleInfo.aboutMe ?? '',
            textAlign: TextAlign.center,
            style: TextStyle(
              fontSize: 12.sp,
              color: const Color(0xb3000000),
              fontWeight: FontWeight.w500,
            ),
          ),
        ),
      ],
    );
  }

  Widget _buildImageWidget() {
    var width = screenWidth;
    var height = width / 1.506024096385542;
    return SizedBox(
      width: width,
      height: height + 35.w,
      child: Stack(
        alignment: Alignment.bottomCenter,
        children: [
          Positioned(
              left: 0,
              right: 0,
              bottom: 35.w,
              child: NetImageLoadUtils.load(
                roleInfo.avatar,
                width,
                height,
                isSetRadius: true,
                borderRadius:
                    const BorderRadius.vertical(bottom: Radius.circular(32)),
              )),
          CustomStyleBg(
            width: 102.w,
            height: 102.w,
            borderWidth: 2.w,
            color: Colors.transparent,
            borderRadius: 32,
            alignment: Alignment.topCenter,
            child: NetImageLoadUtils.load(
              roleInfo.avatar,
              98.w,
              96.w,
              isSetRadius: true,
              radius: 29,
            ),
          )
        ],
      ),
    );
  }
}
